<template>
	<view style="padding: 20rpx 20rpx 100rpx 20rpx">
		<!-- #ifdef H5 || APP-PLUS -->
		<text v-html="val"></text>
		<!-- #endif -->
		<!-- #ifndef H5 -->
		<rich-text :nodes="val" />
		<!-- #endif -->
	</view>
</template>

<script>
import {updateDynamicVariable,getCurrentText} from '../prot.js'
	export default {
		data() {
			return {
				val: '',
				store:''
			}
		},
		onLoad(pay) {
			
			
			if(pay.store_name){
			// document.title = pay.store_name
			
			// updateDynamicVariable(pay.store_name)
			// this.val=getCurrentText()
			this.store= pay.store_name
		
			}
			console.log(pay);
			if(!pay.key){
				
				return uni.showToast({
					title:'参数异常',
					icon:'none'
				})
			}
			
			const fun = this.selXy
			uni.showLoading({
				title:'加载中'
			})
			uni.request({
				url: `https://src-alpha.oss-cn-hangzhou.aliyuncs.com/pro/contract/1041/1053?v=`+new Date().getTime(),
				header: {
					'Cache-Control': 'no-cache',
					'Pragma': 'no-cache'
				},
				success(res) {
					const {
						statusCode,
						data
					} = res
					if (statusCode == 200 && Array.isArray(data)) {
						fun(data, pay.key)
						console.log(data);
					}
				},
				fail() {
					uni.showToast({
						title:'网络异常',
						icon:'none'
					})
				},
				complete() {
					uni.hideLoading()
				}
			})
		},
		methods: {
			selXy(data_list, key) {
				console.log(data_list,'2');
				const info = data_list.find(item => {
					if (key == 'hyxy' && item.name == '金属狗健身会员协议') {
						console.log(item);
						return true
					}
					if (key == 'shxy' && item.name == '会员售后协议') {
						return true
					}
					console.log(key, item.name);
				})
			
				//标题
				if(info){
					document.title = info.title
					if(this.store){
						let tmp=info.text.replace('山','')
						
						let text=tmp.replace('东辰十三健身集团有限公司',this.store)
						this.val = text
					}
					else{
						this.val=info.text
					}
					
				}
				else{
					// uni.showToast({
					// 	title:'参数异常',
					// 	icon:'none'
					// })
				}
				
			
			}
		}
	}
</script>

<style>
	
</style>